﻿<div class="largeLoginForm">
    <h3>Hier anmelden</h3>
    <p>
        Normally, both your asses would be dead as fucking fried chicken, but you happen to pull this shit while I'm in a transitional period so I don't wanna kill you, I wanna help you.    
    </p>
    @{
        using (var form = Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-inline", role = "form" }))
        {
            <br />
            <div>
                <label for="loginEMail">E-Mailaddresse</label>
                <input type="text" class="form-control" id="loginEMail" name="username" placeholder="E-Mail ... ">
            </div>
            <br />
            <div>
                <label for="loginPassword">Passwort</label>
                <input type="password" class="form-control" id="loginPassword" name="password" placeholder="Passwort... ">
            </div>
            <br />
            <button id="loginFormLoginButton" class="btn btn-success" type="submit">Anmelden</button>
            <button id="loginFormRegisterNowButton" data-toggle="modal" href="#registerUserDialog" class="btn btn-primary">Jetzt Registrieren!</button>  
        }
    }
</div>


<div class="modal fade" id="registerUserDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Neuer Zugang registrieren</h4>
            </div>
            <div class="modal-body">
                <div id="registerErrors" class="alert alert-danger" style="display: none;">
                    <ul data-bind="foreach: NewAccountModel.Errors.Items">
                        <li data-bind="text: $data"></li>
                    </ul>
                </div>
                <p>
                    Normally, both your asses would be dead as fucking fried chicken, but you happen to pull this shit while I'm in a transitional period so I don't wanna kill you, I wanna help you. 
                </p>
                <form role="form" class="form-horizontal">
                    <div class="form-group">
                        <label for="registerUserDialogVorname" class="col-sm-4 control-label">Vorname</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="registerUserDialogVorname" data-bind="value: NewAccountModel.Vorname">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="registerUserDialogNachname" class="col-sm-4 control-label">Nachname</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="registerUserDialogNachname" data-bind="value: NewAccountModel.Nachname">
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="form-group">
                        <label for="registerUserDialogEMail" class="col-sm-4 control-label">E-Mail</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="registerUserDialogEMail" data-bind="value: NewAccountModel.EMail">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="registerUserDialogEMailWH" class="col-sm-4 control-label">E-Mail widerholen</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="registerUserDialogEMailWH" data-bind="value: NewAccountModel.EMailWh">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="registerUserDialogPasswort" class="col-sm-4 control-label">Passwort</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control" id="registerUserDialogPasswort" data-bind="value: NewAccountModel.Password">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="registerUserDialogPasswortWH" class="col-sm-4 control-label">Passwort widerholen</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control" id="registerUserDialogPasswortWH" data-bind="value: NewAccountModel.PasswordWH">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="registerUserDialogPasswortWH" class="col-sm-4 control-label"></label>
                        <div class="col-sm-8">
                            <input id="registerUserDialogCheckbox" type="checkbox" />
                            Ich akzeptiere die Nutzungsbedinungen
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button id="registerFormNewAccountCancelButton" type="button" class="btn btn-default" data-dismiss="modal">Abbrechen</button>
                <button id="registerFormNewAccountButton" type="button" class="btn btn-primary">Registrieren</button>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">


    $(document).ready(function () {

        $("#registerFormNewAccountButton").click(function () {
            registerNewAccount();
        });

    });

    function registerNewAccount() {
        $.ajax({
            type: 'POST',
            url: '@Url.Action("Register", "Account")',
            data: model.NewAccountModel.JsonObj(),
            dataType: 'json',
            success: function (data) {

                model.NewAccountModel.Merge(data);

                if (model.NewAccountModel.Errors.HasErrors() == false) {
                    model.NewAccountModel.Clear();
                    $('#registerUserDialog').modal('hide');
                       
                    bootbox.dialog({
                        message: "Ihr Zugang zu unserem Portal wurde erstellt. Sie können sich nun über die Anmeldefunktion auf der Startseite einloggen.",
                        title: "Zugang erfolgreich erstellt",
                        buttons: {
                            main: {
                                label: "Ok",
                                className: "btn-default",
                                callback: function () {
                                }
                            }
                        }
                    });

                }
                else {
                    $("#registerErrors").fadeIn();
                }
            }
        });
    }

</script>
